package com.bbs.dao;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.log4j.Logger;

import com.bbs.action.BaseAction;

public class BaseDao {
	public SqlSession sqlSession;
	public Logger logger = Logger.getLogger(BaseDao.class);
	public BaseDao() throws IOException {
		sqlSession=getSqlSesion();
	}
	//get sqlSsion
	public SqlSession getSqlSesion() throws IOException{
		Reader reader = Resources.getResourceAsReader("ibatis_config.xml"); 
		SqlSessionFactory sqlSessionFactory =  new SqlSessionFactoryBuilder().build(reader); 
		return  sqlSessionFactory.openSession(); 
	}
}
